package com.nav.tictactoe;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class ConnectionAcceptor implements Runnable {
	WaitActivity act;
	public ConnectionAcceptor(WaitActivity act) {
		this.act = act;
	}
	public void run() {
		try {
			SharedData.opponent = SharedData.socket.accept();
        	BufferedReader inReader = new BufferedReader(new InputStreamReader(SharedData.opponent.getInputStream()));
        	String line = inReader.readLine();
    		act.opponent.setText(line.substring(1));
    		inReader.close();
    		act.startBut.setEnabled(true);
		} catch(Exception e) {
			// TODO alert user with error if happens for few times
			e.printStackTrace();
		}
	}
}
